vec4 dataInterpolation(sampler3D data, const vec3 texCoordinates);

vec3 gradient( sampler3D data, const float scaleValue, const vec3 texCoord, const float voxelSpacing )
{
      vec3 delX = vec3(voxelSpacing, 0.0, 0.0);
      vec3 delY = vec3(0.0, voxelSpacing, 0.0);
      vec3 delZ = vec3(0.0, 0.0, voxelSpacing);
      //
      // Sample the texture
      //
      vec3 newVector = vec3(gl_TexCoord[0].xyz);
      vec3 newVectorX = newVector + delX;
      vec3 newVectorY = newVector + delY;
      vec3 newVectorZ = newVector + delZ;
      vec4 cx = dataInterpolation(data, newVectorX);
      vec4 cy = dataInterpolation(data, newVectorY);
      vec4 cz = dataInterpolation(data, newVectorZ);
      //
      // Calculate the gradient vector at the sample position.
      // 	
      vec3 grad;
      grad.x = (cx.a-scaleValue) / voxelSpacing;
      grad.y = (cy.a-scaleValue) / voxelSpacing;
      grad.z = (cz.a-scaleValue) / voxelSpacing;
      return grad;
} 